class EventBus {
    constructor() {
        this.events = []
    }
    on(eventName, cb) {
        this.events.push({
            eventName,
            cb
        })
    }
    emit(eventName, ...params) {
        for(let i = 0; i < this.events.length; i++) {
            if(this.events[i].eventName === eventName) {
                console.log(this.events);
                this.events[i].cb.call(this, ...params)
            }
        }
    }
}
const eventBus = new EventBus()
eventBus.on('test', (age, height) => {
    console.log('我是test啦', '我' + age + '啦' + height);
})
eventBus.emit('test', 20, 30)
